﻿<%@ Page Language="C#" Title="路网管理" MasterPageFile="~/W_View/PageMaster.Master" CodeBehind="B_RoadnetPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Basis.B_RoadnetPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/dropdown.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Jquery/ajaxfileupload.js")%>

    <script type="text/javascript">


        /**
        * 提交表表单数据
        **/
        function Sava(dg, dlg, fm) {

            $.messager.progress({
                title: '请等待',
                msg: '加载数据中...'
            });

            if (!fm) fm = $("form");
            $.ajax({
                type: "POST",
                url: "/api/roadnet",
                data: {
                    'Roadnet_Id': $("input[name='Roadnet_Id']").val(),
                    'Roadnet_Name': $("input[name='Roadnet_Name']").val(),
                    'Admdiv': $("input[name='Admdiv']").val(),
                    'Admgrd': $("#Admgrd").combobox('getValues').join(","),
                    'Rdclass_Dictid': $("#Rdclass_Dictid").combobox('getValues').join(","),
                    'Pvmttype': $("#Pvmttype").combobox('getValues').join(","),
                    'Manaut': $("input[name='Manaut']").val()
                },
                complete: function () {
                    $.messager.progress('close');
                },
                success: function (msg) {
                    if (msg.length >= 1) {
                        $.messager.alert('错误提示', msg, "error");
                    }
                    else {
                        dg.data().datagrid.selectRowIndex = null;
                        dg.datagrid('reload');
                        dlg.dialog('close');
                    }
                },
                error: printError
        });
        
        }
        //添加，编辑窗口的打开
        function B_RoadnetEdit(flag) {
            var row = $('#dg').datagrid('getSelected');
            var title = "";
            if (flag == 0) {
                if (!row) {
                    $.messager.alert('消息提示', '编辑数据时，请选择一项!', 'warning');
                    return;
                }
                $('#fm').form('load', row);
                title = "新增测试数据";
            }
            else {
                $('#fm').form('clear');
                title = "编辑测试数据";
            }

            $('#dlg').dialog('open');
        }
        //删除操作
        function B_RoadnetDel() {
            var row = $('#dg').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '删除数据时，请选择一项!', 'warning');
                return;
            }

            deleteData($('#dg'), $('#dlg'), "/api/roadnet");
        }

        function search(n, o) {
            var road = $('#cmbRoads').combobox("getValue");

            var url = '/api/roadnet';
            var urlParam = "";
            if (road != "" && road != "0") urlParam += "road=" + encodeURI(road) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }


        $(function () {
            var number = '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';

            loadAdmDiv();
            dataGridBind($('#dg'), '/api/roadnet', '路网管理', $('#tb'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });
        })

    </script>    

    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="dg" class="easyui-datagrid content-place"  ajaxCached="false"  >
        <thead>
            <th data-options="field:'Roadnet_Id',editor:'text',width:80,align:'right',hidden:true">ID</th>
            <th data-options="field:'Roadnet_Name',editor:'text',width:150,align:'right' ">路网名称</th>
            <th data-options="field:'Admdiv',editor:'text',width:150,align:'right'" formatter="formatAdmdiv">行政区域</th>
            <th data-options="field:'Admgrd',editor:'text',width:150,align:'right'" formatter="formatAdmgrdS">行政等级</th>
            <th data-options="field:'Rdclass_Dictid',text:'text',width:150,align:'right'" formatter="formatRoadClassS">技术等级</th>
            <th data-options="field:'Pvmttype',editor:'text',width:150,align:'right'" formatter="formatPvmttypeS">路面类型</th>
            <th data-options="field:'Manaut',editor:'text',width:150,align:'right'">管养单位</th>
        </thead>
    </table>
   
    <div id="tb">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="B_RoadnetEdit(-1)">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="B_RoadnetEdit(0)">编辑</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="B_RoadnetDel()">删除</a>
    </div>


    
    <div id="dlg" class="easyui-dialog" title="保存数据" style="width:500px;height:400px;padding:10px" closed="true"  data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttons'">
        <form id="fm" method="post" action="/api/roadnet">
            <table>		
                 <tr style="display:none">
                    <td>ID:</td>
                    <td><input name='Roadnet_Id' class='easyui-validatebox easyui-textbox'  /></td>
                </tr>	     
                <tr>
                    <td>路网名称:</td>
                    <td><input name='Roadnet_Name' class='easyui-validatebox  easyui-textbox'  data-options="required:true"/></td>
                </tr>

                <tr>
                    <td>行政区域:</td>                    
	                <td><input name='Admdiv'  class="easyui-combotree" style="width:200px" data-options="required:true,prompt:'行政区域',url:'/api/data/regioncode',method:'get'"/>
                </tr>

                 <tr>
                    <td>行政等级:</td>    
                    <td><input id="Admgrd" name='Admgrd'  class="easyui-combobox" style="width:300px" data-options="required:true,prompt:'行政等级',valueField:'id',textField:'text',url:'/api/data/adminlevel',method:'get',multiple:true"/>
                </tr>

                 <tr>
                    <td>技术等级:</td>    
                    <td><input id="Rdclass_Dictid" name='Rdclass_Dictid'  class="easyui-combobox" style="width:300px" data-options="required:true,prompt:'技术等级',valueField:'id',textField:'text',url:'/api/data/roadclass',method:'get',multiple:true"/>
                </tr>

               <tr>
                   <td>路面类型:</td>                    
                   <td><input id="Pvmttype"  name='Pvmttype'  class="easyui-combobox" style="width:300px" data-options="required:true,prompt:'路面类型',valueField:'id',textField:'text',url:'/api/data/pavement',method:'get',multiple:true"/></td>
               </tr>

                <tr>
                    <td>管养单位:</td>
                    <td><input name='Manaut' class='easyui-validatebox easyui-textbox' style="width:300px"  data-options="validType:'MaxLength[1000]'"/></td>
                </tr>
                
		    </table>
        </form>
    </div>

     <div id="dlg-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:Sava($('#dg'),$('#dlg'))">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">取消</a>
	</div>
    

    
</asp:Content>

